﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace Hsp.Media.Model.Models
{
    public partial class MediaContext : DbContext
    {
        public MediaContext()
        {
        }

        public MediaContext(DbContextOptions<MediaContext> options)
            : base(options)
        {
        }

        public virtual DbSet<KnowledgeCsharpKeyword> KnowledgeCsharpKeywords { get; set; } = null!;
        public virtual DbSet<MediaSubtitleContent> MediaSubtitleContents { get; set; } = null!;
        public virtual DbSet<MediaSubtitleFile> MediaSubtitleFiles { get; set; } = null!;

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Data Source=127.0.0.1;Initial Catalog=Media;Integrated Security=False;User ID=sa;Password=sa@123;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<KnowledgeCsharpKeyword>(entity =>
            {
                entity.ToTable("Knowledge_CSharp_Keywords");

                entity.HasComment("CSharp关键字");

                entity.Property(e => e.Id).HasComment("ID");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("(getdate())")
                    .HasComment("添加时间");

                entity.Property(e => e.Explanation)
                    .HasMaxLength(255)
                    .IsUnicode(false)
                    .HasComment("内容解释");

                entity.Property(e => e.Keywords)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("关键字");

                entity.Property(e => e.ModifiedTime)
                    .HasColumnType("datetime")
                    .HasComment("修改时间");
            });

            modelBuilder.Entity<MediaSubtitleContent>(entity =>
            {
                entity.ToTable("Media_Subtitle_Content");

                entity.HasComment("字幕内容表");

                entity.Property(e => e.Id).HasComment("ID");

                entity.Property(e => e.Chinese)
                    .HasMaxLength(255)
                    .IsUnicode(false)
                    .HasComment("中文");

                entity.Property(e => e.EndTime)
                    .HasColumnType("time(3)")
                    .HasComment("截止时序");

                entity.Property(e => e.English)
                    .HasMaxLength(255)
                    .IsUnicode(false)
                    .HasComment("英文");

                entity.Property(e => e.FileId).HasComment("文件ID");

                entity.Property(e => e.Seq).HasComment("序号");

                entity.Property(e => e.StartTime)
                    .HasColumnType("time(3)")
                    .HasComment("开始时序");
            });

            modelBuilder.Entity<MediaSubtitleFile>(entity =>
            {
                entity.ToTable("Media_Subtitle_Files");

                entity.HasComment("字幕文件表");

                entity.Property(e => e.Id).HasComment("ID");

                entity.Property(e => e.Chinese)
                    .HasMaxLength(255)
                    .IsUnicode(false)
                    .HasComment("中文名");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("(getdate())")
                    .HasComment("添加时间");

                entity.Property(e => e.English)
                    .HasMaxLength(255)
                    .IsUnicode(false)
                    .HasComment("英文名");

                entity.Property(e => e.FileName)
                    .HasMaxLength(255)
                    .IsUnicode(false)
                    .HasComment("文件名");

                entity.Property(e => e.FileName)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("文件编码格式");

                entity.Property(e => e.ModifiedTime)
                    .HasColumnType("datetime")
                    .HasComment("修改时间");

                entity.Property(e => e.Remark)
                    .HasMaxLength(255)
                    .IsUnicode(false)
                    .HasComment("备注");

                entity.Property(e => e.TypeId).HasComment("字幕类型：0-中文；1-英文；2-中文+英文；");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
